package com.gm.wholesale.network;

import com.gm.wholesale.module.user.UserDataManger;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class RetrofitHeaderInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        Request.Builder requestBuilder;
        requestBuilder = request.newBuilder();
        if (UserDataManger.newInstance().getToken()!=null){
            requestBuilder.addHeader("Authorization", UserDataManger.newInstance().getToken());
        }
        Request request2 = requestBuilder.build();
        return chain.proceed(request2);

    }
}
